const app = getApp()
const util = require('../../../../../../utils/util.js');
const api = require('../../../../../../config/api.js');
Page({
  data: {
    themeid: "",
    resultInfo: {}
  },
  onLoad: function (options) {
    var _this = this;
    _this.setData({
      themeid: options.themeid
    })
    _this.getThemeProblemStatistics();
  },
  /**
   * 获取统计详情
   */
  getThemeProblemStatistics: function () {
    var _this = this;
    var themeid = _this.data.themeid;
    var openid = app.globalData.logininfo.openid;;
    if (openid != null && openid != "") {
      // 已登录
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var data = {};
        data.openid = openid;
        data.themeid = themeid;
        data.access_token = res.access_token;
        util.post(api.Interest_GetThemeProblemStatisticsApi, data).then(res => {
          console.log(res);
          if (res.code == 200) {
            _this.setData({
              resultInfo: res.result
            })
          }
        })
      })
    }
  },
})